package icu.zlz.common.mongodb.entity;

import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.index.IndexDirection;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import java.time.LocalDateTime;

@Document(collection = "msg")
@CompoundIndexes({

})
public class MqttRecord {
    /**
     * 消息id
     */
    @Id
    private String id;
    /**
     * 主题Id
     */
    @Indexed(unique = false)
    private Long topicId;
    /**
     * 消息内容
     */
    private String payload;
    /**
     * 消息时间
     */
    @Indexed(unique = false,direction= IndexDirection.DESCENDING, background = true)
    private LocalDateTime timestamp;
    /**
     * 发送者客户端Id
     */
    private String clientId;
    /**
     * 消息qos级别
     */
    private int qos;
    /**
     * 发送者用户名
     */
    private String username;
    /**
     * 消息节点
     */
    private String node;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Long getTopicId() {
        return topicId;
    }

    public void setTopicId(Long topicId) {
        this.topicId = topicId;
    }

    public String getPayload() {
        return payload;
    }

    public void setPayload(String payload) {
        this.payload = payload;
    }

    public LocalDateTime getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(LocalDateTime timestamp) {
        this.timestamp = timestamp;
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public int getQos() {
        return qos;
    }

    public void setQos(int qos) {
        this.qos = qos;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getNode() {
        return node;
    }

    public void setNode(String node) {
        this.node = node;
    }
}
